import React, { Component } from "react";
import { NavBar } from "antd-mobile";
import styles from './index.module.scss'
// withRouter 让组件用友路由信息（ this.props.history）
// static defaultProps  = {} 给组件的props 设置默认值
// this.props.children 是React中的插槽
// {...this.props}  解构所有父组件传递过来的属性
import { withRouter } from 'react-router-dom'
export default withRouter(
  class MyNavBar extends Component {
    static defaultProps = {
        title:'好客租房',
        mode:'light',
        fistyle:0
    }
    render() {
        const { history, title, children, mode, rightContent,fistyle } = this.props
      return (
        <div className={styles.rooms}>
          <NavBar
            // 默认的返回图标
            icon={<i className="iconfont icon-back" />}
            // 点击左边返回上一页效果
            onLeftClick={() => history.goBack()}
            mode={mode}
            rightContent={rightContent}
            className={fistyle > 1 ? styles.roclass : ''}
            // {...this.props}
          >
             {children || title}
          </NavBar>
        </div>
      );
    }
  }
);
